package indi.chengx.walty;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Config {
	/*
	 * the IMAGING NOVA72XAUM formats [640/480,1280/720,1920/1080,2592/1944]
	 * video/x-raw, format=(string)GRAY8, width=(int)2592, height=(int)1944, framerate=(fraction){ 15/2, 7/1, 6/1, 5/1 };
	 * video/x-raw, format=(string)GRAY8, width=(int)1920, height=(int)1080, framerate=(fraction){ 15/1, 10/1, 15/2, 5/1 };
	 * video/x-raw, format=(string)GRAY8, width=(int)1280, height=(int)720, framerate=(fraction){ 30/1, 25/1, 15/1, 10/1 };
	 * video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)480, framerate=(fraction){ 60/1, 30/1, 25/1, 15/1 };
	 * */
	public static int CAP_WIDTH;
	public static int CAP_HEIGHT;
	
	//SAVE PATH
	//public static final String IMAGE_SAVE_PATH = "/home/walty/Pictures/image-%d.jpg";
	
	//gst-launch command
	//public static final String LAUNCH_COMMAND = "tcambin name=src ! videoconvert ! capsfilter caps=video/x-raw,width=640,height=480";
	//public static final String LAUNCH_COMMAND = "tcambin name=src ! videoconvert ! capsfilter caps=video/x-raw,width="+CAP_WIDTH+",height=" + CAP_HEIGHT;
	//public static final String LAUNCH_COMMAND_SAVE = "tcambin name=src ! videoscale ! jpegenc ! multifilesink name=photo_sink post-messages=true";
	public static String DEFAULT_LAUNCH_COMMAND = "tcambin name=src Exposure_Auto=false ! capsfilter caps=video/x-raw,width=640,height=480 ! tee name=t t. ! queue ! valve name=valve ! videoconvert ! jpegenc ! multifilesink name=filesink post-messages=true location=/home/walty/Pictures/image-%d.jpg t. ! queue ! videoconvert ! appsink name=appsink";
	//public static final String LAUNCH_COMMAND = "v4lsrc ! tee ! queue ! appsink name=appsink ! queue ! ffmpegcolorspace ! fakesink";
	public static String LAUNCH_COMMAND;
	
	static {
		Properties properties = new Properties();
		try {
			InputStream is = new FileInputStream(new File("config/config.properties"));
			properties.load(is);
			CAP_WIDTH = Integer.parseInt(properties.getProperty("default_width", "640"));
			CAP_HEIGHT = Integer.parseInt(properties.getProperty("default_height", "480"));
			LAUNCH_COMMAND = properties.getProperty("launch_command",DEFAULT_LAUNCH_COMMAND);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
			System.out.println("Can't find config.properties");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		
	}
}
